package com.kobeliu.entity;

/**
 * @Author: Kobe_Liu
 * @Date: 2021/12/10 14:54
 */
public class Demo_80_No2123 {

    public static void main(String[] args) {



        System.out.println(orchestraLayout(2511,1504,2235));
    }


    public static int orchestraLayout(int num, int xPos, int yPos) {
        if(xPos==0){
            return (1+yPos)%9;
        }
        //找这个坐标是第几圈
        // y上的第几圈
        int times1 = (num-1-xPos > xPos? xPos:num-1-xPos)+1;
        //x上的第几圈
        int times2 = (num-1-yPos > yPos? yPos:num-1-yPos)+1;

        //圈数
        int time_q = 0;
        //某一圈的第几个
        int time_t = 0;
        if(times1<times2){
            time_q = times1;
            time_t = xPos+yPos-time_q*2-1;
        }else{
            time_q = times2;
            time_t = xPos+yPos-time_q*2+3;
        }
        //第time_q圈第time_t个
        int num1 = num*num - (num-time_q+1)*(num-time_q+1)+time_t;
        return num1%9;


    }
}
